

from Base.Base import Base
from selenium.webdriver.common.by import By
import time
class Page1(Base):
    # 点击首页登录 请登录
    login = (By.LINK_TEXT, '请登录')
    # 账号输入款 id="userName"
    name = (By.ID, 'userName')
    # 密码输入款 id="password"
    password = (By.ID, 'password')
    # 点击登录按钮 name="bi_Usuallogin"
    sbumit = (By.NAME, 'bi_Usuallogin')
    # 点击确认
    quer = (By.XPATH, '//*[@id="bindSub"]')
    #搜索框 name="key"
    key1=(By.NAME,'key')
    #回车事件
    #点击商品
    shangpin=(By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[1]/div[2]/div[1]/a/img')
    #窗口切换技术
    #选择数量 id="_nub"
    nub_loc=(By.ID,'_nub')
    #点击加入购物车 id="addToCartForDetail"
    addToCartForDetail_loc=(By.ID,'addToCartForDetail')
    #点击查看购物车 name="detail_chakangouwuche"
    detail_chakangouwuche=(By.NAME,'detail_chakangouwuche')


    #调用上面写好的页面元素 登录
    def login1(self):
        #点击请登录
        self.click(self.login)
        #账号输入框
        self.send_keys(self.name,'18696472858')
        #密码输入框
        self.send_keys(self.password,'123456Aa')
        time.sleep(20)
        #点击登录按钮
        self.click(self.sbumit)
        time.sleep(5)
        #点击确认按钮
        self.click(self.quer)


    #搜索商品
    def shangp1(self):
        self.send_keys(self.key1,'茅台')
        self.key(self.key1)

    #点击商品
    def gou(self):
        self.click(self.shangpin)
        time.sleep(5)
        self.window()


    #选择数量
    def nub(self):
        self.click(self.nub_loc)
        self.send_keys(self.nub_loc,10)
        time.sleep(5)
        self.click(self.addToCartForDetail_loc)
        self.click(self.detail_chakangouwuche)
        time.sleep(5)

